<%@page import="br.com.pegasi.util.Arquivo"%>
<%@page import="java.io.*, org.xhtmlrenderer.pdf.ITextRenderer" %>

<%
        String pdf = 
                (String) session.getAttribute("pdf");

        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocumentFromString(pdf);

        String outputFile = "c://temp//relatorio.pdf";
        OutputStream os = new FileOutputStream(outputFile);
        renderer.layout();
        renderer.createPDF(os);
        os.close();

        File arq = new File(outputFile);
        byte[] b = Arquivo.getByteFile(arq);

        response.setContentType("application/pdf");
        response.setHeader("Cache-Control", "max-age=30");
        response.setHeader("Pragma", "No-cache");
        response.setDateHeader("Expires", 0);
        response.setContentLength(b.length);


        ServletOutputStream otp = response.getOutputStream();

        otp.write(b, 0, b.length);


        otp.flush();
        otp.close();
%>


